import axios from "axios";
import {store} from "../redux/store";

// 封装axios的请求的基本路径
axios.defaults.baseURL = "http://localhost:5000";

axios.interceptors.request.use((config)=>{
    store.dispatch({
        type:"change_loading",
        payload:true
    })
    return config;
},(error)=>{
    return Promise.reject(error);
});

axios.interceptors.response.use((res)=>{
    store.dispatch({
        type:"change_loading",
        payload:false
    })
    return res;
},(error)=>{
    store.dispatch({
        type:"change_loading",
        payload:false
    })
    return Promise.reject(error);
})
